
import os
import os.path

import logging

LOG_PATH = "./log/"

def create_weblog():
    logpath = os.path.join(LOG_PATH, "web_api.log")
    weblog = logging.getLogger("weblog")
    weblog.setLevel(level=logging.DEBUG)
    handler = logging.FileHandler(logpath)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('[%(asctime)s][%(levelname)s][%(name)s][%(thread)d][%(funcName)s] - %(message)s')
    handler.setFormatter(formatter)
    weblog.addHandler(handler)

def create_tasklog():
    logpath = os.path.join(LOG_PATH, "task_manage.log")
    tasklog = logging.getLogger("tasklog")
    tasklog.setLevel(level=logging.INFO)
    handler = logging.FileHandler(logpath)
    handler.setLevel(logging.INFO)
    formatter = logging.Formatter('[%(asctime)s][%(levelname)s][%(name)s][%(thread)d][%(funcName)s] - %(message)s')
    handler.setFormatter(formatter)
    tasklog.addHandler(handler)

def create_handlelog():
    logpath = os.path.join(LOG_PATH, "message_handle.log")
    handlelog = logging.getLogger("handlelog")
    handlelog.setLevel(level=logging.INFO)
    handler = logging.FileHandler(logpath)
    handler.setLevel(logging.INFO)
    formatter = logging.Formatter('[%(asctime)s][%(levelname)s][%(name)s][%(thread)d][%(funcName)s] - %(message)s')
    handler.setFormatter(formatter)
    handlelog.addHandler(handler)



create_weblog()
create_tasklog()
create_handlelog()
